-
Notifications
You must be signed in to change notification settings - Fork 465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: allow noncomputable unsafe
definitions
#3647
Conversation
Mathlib CI status (docs):
|
For future reference, here is some additional info on the motivation behind this PR. Alloy allow users to external (C) implementations to definitions via Lean code. This is done via metaprogramming utilities, but is essentially equivalent to a definition followed an alloy c extern def myAdd (x y : UInt32) : UInt32 := {
return x + y;
} is essentially equivalent to: noncomputable opaque myAdd (x y : UInt32) : UInt32
attribute [extern "alloy_myAdd"] myAdd
alloy c section
LEAN_EXPORT uint32_t alloy_myAdd ( uint32_t x , uint32_t y ) {
return x + y;
}
end Libraries which use Alloy may define functions that perform actions that are morally impure or memory-unsafe. Thus, the library creators would like to mark the definition alloy c extern unsafe def myAdd (x y : UInt32) : UInt32 would produce: noncomputable unsafe opaque myAdd (x y : UInt32) : UInt32 which is forbidden. The goal of this PR is to allow such a use case. The use of |
Enables the combination of
noncomputable unsafe
to be used for definitions. Outside of pure theory,noncomputable
is also useful to prevent Lean from compiling a definition which will be implemented with external code later. Such definitions may also wish to be markedunsafe
if they perform morally impure or memory-unsafe functions.